package com.desire.controller;

import com.desire.bean.User;
import com.desire.remote.UserRemoteClient;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description:
 * @Author: littleDesire
 * @Date: 2022-06-09 9:42
 * @Version: 1.0
 */
@RestController
public class UserController implements UserRemoteClient {
    /**
     * 普通方式调用
     */
    @Override
    public Map<String, Object> queryUser() {
        System.out.println("查询-----》》》");
        Map<String, Object> map = new HashMap<>();
        map.put("id", "001");
        map.put("name", "desire");
        return map;
    }

    /**
     * 路径传值方式调用
     */
    @Override
    public Map<String, Object> queryPath(String id) {
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        return map;
    }


    /**
     * 普通带参方式调用
     */
    @Override
    public Map<String, Object> queryParams(String username, String password) {
        Map<String, Object> map = new HashMap<>();
        map.put("username", username);
        map.put("password", password);
        return map;
    }

    /**
     * map传值方式调用 get
     */
    @Override
    public void queryGetMap(Map<String, Object> map) {
        System.out.println(map.get("id"));
        System.out.println(map.get("name"));
    }

    /**
     * map传值方式调用 post
     */
    @Override
    public void queryPostMap(Map<String, Object> map) {
        System.out.println(map.get("id"));
        System.out.println(map.get("name"));
    }

    /**
     * 对象传值方式调用
     */
    @Override
    public void queryPostUser(User user) {
        System.out.println(user.getAge());
        System.out.println(user.getName());
    }

    /**
     * SpringQueryMap 官方的传值方式
     */
    @Override
    public void queryStringQueryMap(Map<String, Object> map) {
        System.out.println(map.get("id"));
        System.out.println(map.get("name"));
    }

    /**
     * SpringQueryMap 官方的传值方式 User
     */
    @Override
    public void queryStringQueryMapUser(User user) {
        System.out.println(user.getAge());
        System.out.println(user.getName());
    }
}
